﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.Common;
using System.Collections;

namespace DALL.LibrarySys
{
    /// <summary>
    /// 数据访问类:T_PUB_LIBRARYMATERIAL
    /// </summary>
    public class T_PUB_LIBRARYMATERIAL
    {
        public T_PUB_LIBRARYMATERIAL()
        { }

        /// <summary>
        /// 更新仓库材料
        /// </summary>
        public void UpdateLibraryMaterial(Model.LibrarySys.T_PUB_LIBRARYOUT model, IList<Model.LibrarySys.T_PUB_LIBRARYMATERIAL> updateList)
        {
            ArrayList strArry = new ArrayList();
            #region 更新出库单
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_PUB_LIBRARYOUT set ");
            if (model.BRANCH_ID != null)
            {
                strSql.Append("BRANCH_ID=" + model.BRANCH_ID + ",");
            }
            else
            {
                strSql.Append("BRANCH_ID= null ,");
            }
            if (model.LIBRARY_ID != null)
            {
                strSql.Append("LIBRARY_ID=" + model.LIBRARY_ID + ",");
            }
            else
            {
                strSql.Append("LIBRARY_ID= null ,");
            }
            if (model.APPLICANT != null)
            {
                strSql.Append("APPLICANT=" + model.APPLICANT + ",");
            }
            else
            {
                strSql.Append("APPLICANT= null ,");
            }
            if (model.APPLY_TIMEOUT != null)
            {
                strSql.Append("APPLY_TIMEOUT='" + model.APPLY_TIMEOUT + "',");
            }
            else
            {
                strSql.Append("APPLY_TIMEOUT= null ,");
            }
            if (model.REAL_TIMEOUT != null)
            {
                strSql.Append("REAL_TIMEOUT='" + model.REAL_TIMEOUT + "',");
            }
            else
            {
                strSql.Append("REAL_TIMEOUT= null ,");
            }
            if (model.PLAN_TIMEIN != null)
            {
                strSql.Append("PLAN_TIMEIN='" + model.PLAN_TIMEIN + "',");
            }
            else
            {
                strSql.Append("PLAN_TIMEIN= null ,");
            }
            if (model.REAL_TIMEIN != null)
            {
                strSql.Append("REAL_TIMEIN='" + model.REAL_TIMEIN + "',");
            }
            else
            {
                strSql.Append("REAL_TIMEIN= null ,");
            }
            if (model.STATE != null)
            {
                strSql.Append("STATE='" + model.STATE + "',");
            }
            else
            {
                strSql.Append("STATE= null ,");
            }
            if (model.REMARK != null)
            {
                strSql.Append("REMARK='" + model.REMARK + "',");
            }
            else
            {
                strSql.Append("REMARK= null ,");
            }
            if (model.TITEL != null)
            {
                strSql.Append("TITEL='" + model.TITEL + "',");
            }
            else
            {
                strSql.Append("TITEL= null ,");
            }
            if (model.APPLY_TIME != null)
            {
                strSql.Append("APPLY_TIME='" + model.APPLY_TIME + "',");
            }
            else
            {
                strSql.Append("APPLY_TIME= null ,");
            }
            if (model.ORDER_ID != null)
            {
                strSql.Append("ORDER_ID=" + model.ORDER_ID + ",");
            }
            else
            {
                strSql.Append("ORDER_ID= null ,");
            }
            if (model.NOTATION != null)
            {
                strSql.Append("NOTATION='" + model.NOTATION + "',");
            }
            else
            {
                strSql.Append("NOTATION= null ,");
            }
            if (model.APPROVER != null)
            {
                strSql.Append("APPROVER=" + model.APPROVER + ",");
            }
            else
            {
                strSql.Append("APPROVER= null ,");
            }
            if (model.APPLICANT_NAME != null)
            {
                strSql.Append("APPLICANT_NAME='" + model.APPLICANT_NAME + "',");
            }
            else
            {
                strSql.Append("APPLICANT_NAME= null ,");
            }
            if (model.APPROVER_NAME != null)
            {
                strSql.Append("APPROVER_NAME='" + model.APPROVER_NAME + "',");
            }
            else
            {
                strSql.Append("APPROVER_NAME= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");
            strSql.Remove(n, 1);
            strSql.Append(" where ID='" + model.ID + "' ");
            strArry.Add(strSql);
            #endregion

            #region 更新仓库材料
            foreach (Model.LibrarySys.T_PUB_LIBRARYMATERIAL item in updateList)
            {
                StringBuilder strSqlm = new StringBuilder();
                strSqlm.Append("update T_PUB_LIBRARYMATERIAL set ");
                if (item.LIBRARY_ID != null)
                {
                    strSqlm.Append("LIBRARY_ID=" + item.LIBRARY_ID + ",");
                }
                else
                {
                    strSqlm.Append("LIBRARY_ID= null ,");
                }
                if (item.MATERIAL_ID != null)
                {
                    strSqlm.Append("MATERIAL_ID=" + item.MATERIAL_ID + ",");
                }
                else
                {
                    strSqlm.Append("MATERIAL_ID= null ,");
                }
                if (item.NUM != null)
                {
                    strSqlm.Append("NUM=" + item.NUM + ",");
                }
                else
                {
                    strSqlm.Append("NUM= null ,");
                }
                if (item.MINVALUE != null)
                {
                    strSqlm.Append("MINVALUE=" + item.MINVALUE + ",");
                }
                else
                {
                    strSqlm.Append("MINVALUE= null ,");
                }
                int m = strSqlm.ToString().LastIndexOf(",");
                strSqlm.Remove(m, 1);
                strSqlm.Append(" where ID=" + item.ID + "");
                strArry.Add(strSqlm);
            }
            #endregion
            DBHelper.ExecuteSqlTran(strArry);
        }


        #region 单个材料入库
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        /// <param name="outmodel"></param>
        public void Update_Material(Model.LibrarySys.T_PUB_LIBRARYMATERIAL model, Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL outmodel)
        {
            ArrayList strArry = new ArrayList();

            #region 更新仓库材料表
             StringBuilder strSqlm = new StringBuilder();
                strSqlm.Append("update T_PUB_LIBRARYMATERIAL set ");
                if (model.LIBRARY_ID != null)
                {
                    strSqlm.Append("LIBRARY_ID=" + model.LIBRARY_ID + ",");
                }
                else
                {
                    strSqlm.Append("LIBRARY_ID= null ,");
                }
                if (model.MATERIAL_ID != null)
                {
                    strSqlm.Append("MATERIAL_ID=" + model.MATERIAL_ID + ",");
                }
                else
                {
                    strSqlm.Append("MATERIAL_ID= null ,");
                }
                if (model.NUM != null)
                {
                    strSqlm.Append("NUM=" + model.NUM + ",");
                }
                else
                {
                    strSqlm.Append("NUM= null ,");
                }
                if (model.MINVALUE != null)
                {
                    strSqlm.Append("MINVALUE=" + model.MINVALUE + ",");
                }
                else
                {
                    strSqlm.Append("MINVALUE= null ,");
                }
                int m = strSqlm.ToString().LastIndexOf(",");
                strSqlm.Remove(m, 1);
                strSqlm.Append(" where ID=" + model.ID + "");
                strArry.Add(strSqlm);
            #endregion

            #region 更新出库单材料表
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update T_PUB_LIBRARYOUTMATERIAL set ");
                if (outmodel.LIBRARYOUTID != null)
                {
                    strSql.Append("LIBRARYOUTID='" + outmodel.LIBRARYOUTID + "',");
                }
                else
                {
                    strSql.Append("LIBRARYOUTID= null ,");
                }
                if (outmodel.MATERIAL_ID != null)
                {
                    strSql.Append("MATERIAL_ID=" + outmodel.MATERIAL_ID + ",");
                }
                else
                {
                    strSql.Append("MATERIAL_ID= null ,");
                }
                if (outmodel.MATERIAL_NAME != null)
                {
                    strSql.Append("MATERIAL_NAME='" + outmodel.MATERIAL_NAME + "',");
                }
                else
                {
                    strSql.Append("MATERIAL_NAME= null ,");
                }
                if (outmodel.NUM != null)
                {
                    strSql.Append("NUM=" + outmodel.NUM + ",");
                }
                else
                {
                    strSql.Append("NUM= null ,");
                }
                if (outmodel.MATERIAL_STATE != null)
                {
                    strSql.Append("MATERIAL_STATE='" + outmodel.MATERIAL_STATE + "',");
                }
                else
                {
                    strSql.Append("MATERIAL_STATE= null ,");
                }
                if (outmodel.RETURN_NUM != null)
                {
                    strSql.Append("RETURN_NUM=" + outmodel.RETURN_NUM + ",");
                }
                else
                {
                    strSql.Append("RETURN_NUM= null ,");
                }
                if (outmodel.DISCARD_ID != null)
                {
                    strSql.Append("DISCARD_ID=" + outmodel.DISCARD_ID + ",");
                }
                else
                {
                    strSql.Append("DISCARD_ID= null ,");
                }
                if (outmodel.TIMEIN != null)
                {
                    strSql.Append("TIMEIN='" + outmodel.TIMEIN + "',");
                }
                else
                {
                    strSql.Append("TIMEIN= null ,");
                }
                if (outmodel.REMARK != null)
                {
                    strSql.Append("REMARK='" + outmodel.REMARK + "',");
                }
                else
                {
                    strSql.Append("REMARK= null ,");
                }
                int n = strSql.ToString().LastIndexOf(",");
                strSql.Remove(n, 1);
                strSql.Append(" where ID=" + outmodel.ID + "");
                strArry.Add(strSql);
            #endregion

                DBHelper.ExecuteSqlTran(strArry);
        }
        #endregion

        #region 单个材料入库
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        /// <param name="outmodel"></param>
        public void Add_Material(Model.LibrarySys.T_PUB_LIBRARYMATERIAL model, Model.LibrarySys.T_PUB_LIBRARYOUTMATERIAL outmodel)
        {
            ArrayList strArry = new ArrayList();

            #region 更新仓库材料表
            //StringBuilder strSqlm = new StringBuilder();
            //strSqlm.Append("update T_PUB_LIBRARYMATERIAL set ");
            //if (model.LIBRARY_ID != null)
            //{
            //    strSqlm.Append("LIBRARY_ID=" + model.LIBRARY_ID + ",");
            //}
            //else
            //{
            //    strSqlm.Append("LIBRARY_ID= null ,");
            //}
            //if (model.MATERIAL_ID != null)
            //{
            //    strSqlm.Append("MATERIAL_ID=" + model.MATERIAL_ID + ",");
            //}
            //else
            //{
            //    strSqlm.Append("MATERIAL_ID= null ,");
            //}
            //if (model.NUM != null)
            //{
            //    strSqlm.Append("NUM=" + model.NUM + ",");
            //}
            //else
            //{
            //    strSqlm.Append("NUM= null ,");
            //}
            //if (model.MINVALUE != null)
            //{
            //    strSqlm.Append("MINVALUE=" + model.MINVALUE + ",");
            //}
            //else
            //{
            //    strSqlm.Append("MINVALUE= null ,");
            //}
            //int m = strSqlm.ToString().LastIndexOf(",");
            //strSqlm.Remove(m, 1);
            //strSqlm.Append(" where ID=" + model.ID + "");
            //strArry.Add(strSqlm);

            StringBuilder strSqlm = new StringBuilder();
            StringBuilder strSqlm1 = new StringBuilder();
            StringBuilder strSqlm2 = new StringBuilder();
            if (model.LIBRARY_ID != null)
            {
                strSqlm1.Append("LIBRARY_ID,");
                strSqlm2.Append("" + model.LIBRARY_ID + ",");
            }
            if (model.MATERIAL_ID != null)
            {
                strSqlm1.Append("MATERIAL_ID,");
                strSqlm2.Append("" + model.MATERIAL_ID + ",");
            }
            if (model.NUM != null)
            {
                strSqlm1.Append("NUM,");
                strSqlm2.Append("" + model.NUM + ",");
            }
            if (model.MINVALUE != null)
            {
                strSqlm1.Append("MINVALUE,");
                strSqlm2.Append("" + model.MINVALUE + ",");
            }
            strSqlm.Append("insert into T_PUB_LIBRARYMATERIAL(");
            strSqlm.Append(strSqlm1.ToString().Remove(strSqlm1.Length - 1));
            strSqlm.Append(")");
            strSqlm.Append(" values (");
            strSqlm.Append(strSqlm2.ToString().Remove(strSqlm2.Length - 1));
            strSqlm.Append(")");
            strSqlm.Append(";select @@IDENTITY");
            strArry.Add(strSqlm);
            #endregion

            #region 更新出库单材料表
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_PUB_LIBRARYOUTMATERIAL set ");
            if (outmodel.LIBRARYOUTID != null)
            {
                strSql.Append("LIBRARYOUTID='" + outmodel.LIBRARYOUTID + "',");
            }
            else
            {
                strSql.Append("LIBRARYOUTID= null ,");
            }
            if (outmodel.MATERIAL_ID != null)
            {
                strSql.Append("MATERIAL_ID=" + outmodel.MATERIAL_ID + ",");
            }
            else
            {
                strSql.Append("MATERIAL_ID= null ,");
            }
            if (outmodel.MATERIAL_NAME != null)
            {
                strSql.Append("MATERIAL_NAME='" + outmodel.MATERIAL_NAME + "',");
            }
            else
            {
                strSql.Append("MATERIAL_NAME= null ,");
            }
            if (outmodel.NUM != null)
            {
                strSql.Append("NUM=" + outmodel.NUM + ",");
            }
            else
            {
                strSql.Append("NUM= null ,");
            }
            if (outmodel.MATERIAL_STATE != null)
            {
                strSql.Append("MATERIAL_STATE='" + outmodel.MATERIAL_STATE + "',");
            }
            else
            {
                strSql.Append("MATERIAL_STATE= null ,");
            }
            if (outmodel.RETURN_NUM != null)
            {
                strSql.Append("RETURN_NUM=" + outmodel.RETURN_NUM + ",");
            }
            else
            {
                strSql.Append("RETURN_NUM= null ,");
            }
            if (outmodel.DISCARD_ID != null)
            {
                strSql.Append("DISCARD_ID=" + outmodel.DISCARD_ID + ",");
            }
            else
            {
                strSql.Append("DISCARD_ID= null ,");
            }
            if (outmodel.TIMEIN != null)
            {
                strSql.Append("TIMEIN='" + outmodel.TIMEIN + "',");
            }
            else
            {
                strSql.Append("TIMEIN= null ,");
            }
            if (outmodel.REMARK != null)
            {
                strSql.Append("REMARK='" + outmodel.REMARK + "',");
            }
            else
            {
                strSql.Append("REMARK= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");
            strSql.Remove(n, 1);
            strSql.Append(" where ID=" + outmodel.ID + "");
            strArry.Add(strSql);
            #endregion

            DBHelper.ExecuteSqlTran(strArry);
        }
        #endregion

        #region 采购入库
        public void AddPurchase(Model.Procurement.T_PUB_WAREHOUSING model, IList<Model.Procurement.T_PUB_PURCHASEMATERIAL> materiallist, IList<Model.LibrarySys.T_PUB_LIBRARYMATERIAL> addList, IList<Model.LibrarySys.T_PUB_LIBRARYMATERIAL> editList)
        {
            ArrayList strArry = new ArrayList();
            #region 添加采购入库记录
            StringBuilder strSql = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();
            if (model.WAREHOUSING_ID != null)
            {
                strSql1.Append("WAREHOUSING_ID,");
                strSql2.Append("'" + model.WAREHOUSING_ID + "',");
            }
            if (model.TIME != null)
            {
                strSql1.Append("TIME,");
                strSql2.Append("'" + model.TIME + "',");
            }
            if (model.APPLICANT != null)
            {
                strSql1.Append("APPLICANT,");
                strSql2.Append("" + model.APPLICANT + ",");
            }
            if (model.APPLICANT_NAME != null)
            {
                strSql1.Append("APPLICANT_NAME,");
                strSql2.Append("'" + model.APPLICANT_NAME + "',");
            }
            if (model.BRANCH_ID != null)
            {
                strSql1.Append("BRANCH_ID,");
                strSql2.Append("" + model.BRANCH_ID + ",");
            }
            if (model.LIBRARY_ID != null)
            {
                strSql1.Append("LIBRARY_ID,");
                strSql2.Append("" + model.LIBRARY_ID + ",");
            }
            if (model.REMARK != null)
            {
                strSql1.Append("REMARK,");
                strSql2.Append("'" + model.REMARK + "',");
            }
            if (model.TITEL != null)
            {
                strSql1.Append("TITEL,");
                strSql2.Append("'" + model.TITEL + "',");
            }
            strSql.Append("insert into T_PUB_WAREHOUSING(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");

            strArry.Add(strSql);
            #endregion

            #region  添加采购材料
            foreach (Model.Procurement.T_PUB_PURCHASEMATERIAL item in materiallist)
            {
                StringBuilder strSqlm = new StringBuilder();
                StringBuilder strSqlm1 = new StringBuilder();
                StringBuilder strSqlm2 = new StringBuilder();
                if (item.PURCHASE_ID != null)
                {
                    strSqlm1.Append("PURCHASE_ID,");
                    strSqlm2.Append("'" + item.PURCHASE_ID + "',");
                }
                if (item.MATERIAL_ID != null)
                {
                    strSqlm1.Append("MATERIAL_ID,");
                    strSqlm2.Append("" + item.MATERIAL_ID + ",");
                }
                if (item.MATERIAL_NAME != null)
                {
                    strSqlm1.Append("MATERIAL_NAME,");
                    strSqlm2.Append("'" + item.MATERIAL_NAME + "',");
                }
                if (item.NUM != null)
                {
                    strSqlm1.Append("NUM,");
                    strSqlm2.Append("" + item.NUM + ",");
                }
                strSqlm.Append("insert into T_PUB_PURCHASEMATERIAL(");
                strSqlm.Append(strSqlm1.ToString().Remove(strSqlm1.Length - 1));
                strSqlm.Append(")");
                strSqlm.Append(" values (");
                strSqlm.Append(strSqlm2.ToString().Remove(strSqlm2.Length - 1));
                strSqlm.Append(")");
                strSqlm.Append(";select @@IDENTITY");
                strArry.Add(strSqlm);
            }
            #endregion

            #region 添加不存在的仓库材料
            foreach (Model.LibrarySys.T_PUB_LIBRARYMATERIAL item in addList)
            {
            StringBuilder strSqla=new StringBuilder();
			StringBuilder strSqla1=new StringBuilder();
			StringBuilder strSqla2=new StringBuilder();
			if (item.LIBRARY_ID != null)
			{
				strSqla1.Append("LIBRARY_ID,");
				strSqla2.Append(""+item.LIBRARY_ID+",");
			}
			if (item.MATERIAL_ID != null)
			{
				strSqla1.Append("MATERIAL_ID,");
				strSqla2.Append(""+item.MATERIAL_ID+",");
			}
			if (item.NUM != null)
			{
				strSqla1.Append("NUM,");
				strSqla2.Append(""+item.NUM+",");
			}
			if (item.MINVALUE != null)
			{
				strSqla1.Append("MINVALUE,");
				strSqla2.Append(""+item.MINVALUE+",");
			}
			strSqla.Append("insert into T_PUB_LIBRARYMATERIAL(");
			strSqla.Append(strSqla1.ToString().Remove(strSqla1.Length - 1));
			strSqla.Append(")");
			strSqla.Append(" values (");
			strSqla.Append(strSqla2.ToString().Remove(strSqla2.Length - 1));
			strSqla.Append(")");
			strSqla.Append(";select @@IDENTITY");
            strArry.Add(strSqla);
            }
            #endregion

            #region 添加存在的仓库材料
            foreach (Model.LibrarySys.T_PUB_LIBRARYMATERIAL item in editList)
            {
                StringBuilder strSqle = new StringBuilder();
                strSqle.Append("update T_PUB_LIBRARYMATERIAL set ");
                if (item.LIBRARY_ID != null)
                {
                    strSqle.Append("LIBRARY_ID=" + item.LIBRARY_ID + ",");
                }
                else
                {
                    strSqle.Append("LIBRARY_ID= null ,");
                }
                if (item.MATERIAL_ID != null)
                {
                    strSqle.Append("MATERIAL_ID=" + item.MATERIAL_ID + ",");
                }
                else
                {
                    strSqle.Append("MATERIAL_ID= null ,");
                }
                if (item.NUM != null)
                {
                    strSqle.Append("NUM=" + item.NUM + ",");
                }
                else
                {
                    strSqle.Append("NUM= null ,");
                }
                if (item.MINVALUE != null)
                {
                    strSqle.Append("MINVALUE=" + item.MINVALUE + ",");
                }
                else
                {
                    strSqle.Append("MINVALUE= null ,");
                }
                int n = strSqle.ToString().LastIndexOf(",");
                strSqle.Remove(n, 1);
                strSqle.Append(" where ID=" + item.ID + "");
                strArry.Add(strSqle);
            }
            #endregion

            DBHelper.ExecuteSqlTran(strArry);
        }
        #endregion

        //#region 采购入库
        //public void AddPurchase(Model.Procurement.T_PUB_WAREHOUSING model, Model.LibrarySys.T_PUB_LIBRARYMATERIAL lmmodel)
        //{
        //    ArrayList strArry = new ArrayList();
        //    #region 添加采购入库记录
        //    StringBuilder strSql = new StringBuilder();
        //    StringBuilder strSql1 = new StringBuilder();
        //    StringBuilder strSql2 = new StringBuilder();
        //    if (model.MATERIAL_ID != null)
        //    {
        //        strSql1.Append("MATERIAL_ID,");
        //        strSql2.Append("" + model.MATERIAL_ID + ",");
        //    }
        //    if (model.MATERIAL_NAME != null)
        //    {
        //        strSql1.Append("MATERIAL_NAME,");
        //        strSql2.Append("'" + model.MATERIAL_NAME + "',");
        //    }
        //    if (model.NUM != null)
        //    {
        //        strSql1.Append("NUM,");
        //        strSql2.Append("" + model.NUM + ",");
        //    }
        //    if (model.TIME != null)
        //    {
        //        strSql1.Append("TIME,");
        //        strSql2.Append("'" + model.TIME + "',");
        //    }
        //    if (model.APPLICANT != null)
        //    {
        //        strSql1.Append("APPLICANT,");
        //        strSql2.Append("" + model.APPLICANT + ",");
        //    }
        //    if (model.APPLICANT_NAME != null)
        //    {
        //        strSql1.Append("APPLICANT_NAME,");
        //        strSql2.Append("'" + model.APPLICANT_NAME + "',");
        //    }
        //    if (model.BRANCH_ID != null)
        //    {
        //        strSql1.Append("BRANCH_ID,");
        //        strSql2.Append("" + model.BRANCH_ID + ",");
        //    }
        //    if (model.LIBRARY_ID != null)
        //    {
        //        strSql1.Append("LIBRARY_ID,");
        //        strSql2.Append("" + model.LIBRARY_ID + ",");
        //    }
        //    if (model.REMARK != null)
        //    {
        //        strSql1.Append("REMARK,");
        //        strSql2.Append("'" + model.REMARK + "',");
        //    }
        //    if (model.TITEL != null)
        //    {
        //        strSql1.Append("TITEL,");
        //        strSql2.Append("'" + model.TITEL + "',");
        //    }
        //    strSql.Append("insert into T_PUB_WAREHOUSING(");
        //    strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
        //    strSql.Append(")");
        //    strSql.Append(" values (");
        //    strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
        //    strSql.Append(")");
        //    strSql.Append(";select @@IDENTITY");

        //    strArry.Add(strSql);
        //    #endregion

        //    #region 更新仓库材料
        //    StringBuilder strSqlm = new StringBuilder();
        //    strSqlm.Append("update T_PUB_LIBRARYMATERIAL set ");
        //    if (lmmodel.LIBRARY_ID != null)
        //    {
        //        strSqlm.Append("LIBRARY_ID=" + lmmodel.LIBRARY_ID + ",");
        //    }
        //    else
        //    {
        //        strSqlm.Append("LIBRARY_ID= null ,");
        //    }
        //    if (lmmodel.MATERIAL_ID != null)
        //    {
        //        strSqlm.Append("MATERIAL_ID=" + lmmodel.MATERIAL_ID + ",");
        //    }
        //    else
        //    {
        //        strSqlm.Append("MATERIAL_ID= null ,");
        //    }
        //    if (lmmodel.NUM != null)
        //    {
        //        strSqlm.Append("NUM=" + lmmodel.NUM + ",");
        //    }
        //    else
        //    {
        //        strSqlm.Append("NUM= null ,");
        //    }
        //    if (lmmodel.MINVALUE != null)
        //    {
        //        strSqlm.Append("MINVALUE=" + lmmodel.MINVALUE + ",");
        //    }
        //    else
        //    {
        //        strSqlm.Append("MINVALUE= null ,");
        //    }
        //    int m = strSqlm.ToString().LastIndexOf(",");
        //    strSqlm.Remove(m, 1);
        //    strSqlm.Append(" where ID=" + lmmodel.ID + "");
        //    strArry.Add(strSqlm);
        //    #endregion

        //    DBHelper.ExecuteSqlTran(strArry);
        //}
        //#endregion


        //#region 采购入库
        //public void EditPurchase(Model.Procurement.T_PUB_WAREHOUSING model, Model.LibrarySys.T_PUB_LIBRARYMATERIAL lmmodel)
        //{
        //    ArrayList strArry = new ArrayList();
        //    #region 添加采购入库记录
        //    StringBuilder strSql = new StringBuilder();
        //    StringBuilder strSql1 = new StringBuilder();
        //    StringBuilder strSql2 = new StringBuilder();
        //    if (model.MATERIAL_ID != null)
        //    {
        //        strSql1.Append("MATERIAL_ID,");
        //        strSql2.Append("" + model.MATERIAL_ID + ",");
        //    }
        //    if (model.MATERIAL_NAME != null)
        //    {
        //        strSql1.Append("MATERIAL_NAME,");
        //        strSql2.Append("'" + model.MATERIAL_NAME + "',");
        //    }
        //    if (model.NUM != null)
        //    {
        //        strSql1.Append("NUM,");
        //        strSql2.Append("" + model.NUM + ",");
        //    }
        //    if (model.TIME != null)
        //    {
        //        strSql1.Append("TIME,");
        //        strSql2.Append("'" + model.TIME + "',");
        //    }
        //    if (model.APPLICANT != null)
        //    {
        //        strSql1.Append("APPLICANT,");
        //        strSql2.Append("" + model.APPLICANT + ",");
        //    }
        //    if (model.APPLICANT_NAME != null)
        //    {
        //        strSql1.Append("APPLICANT_NAME,");
        //        strSql2.Append("'" + model.APPLICANT_NAME + "',");
        //    }
        //    if (model.BRANCH_ID != null)
        //    {
        //        strSql1.Append("BRANCH_ID,");
        //        strSql2.Append("" + model.BRANCH_ID + ",");
        //    }
        //    if (model.LIBRARY_ID != null)
        //    {
        //        strSql1.Append("LIBRARY_ID,");
        //        strSql2.Append("" + model.LIBRARY_ID + ",");
        //    }
        //    if (model.REMARK != null)
        //    {
        //        strSql1.Append("REMARK,");
        //        strSql2.Append("'" + model.REMARK + "',");
        //    }
        //    if (model.TITEL != null)
        //    {
        //        strSql1.Append("TITEL,");
        //        strSql2.Append("'" + model.TITEL + "',");
        //    }
        //    strSql.Append("insert into T_PUB_WAREHOUSING(");
        //    strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
        //    strSql.Append(")");
        //    strSql.Append(" values (");
        //    strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
        //    strSql.Append(")");
        //    strSql.Append(";select @@IDENTITY");

        //    strArry.Add(strSql);
        //    #endregion

        //    #region 更新仓库材料
        //    StringBuilder strSqlm = new StringBuilder();
        //    StringBuilder strSqlm1 = new StringBuilder();
        //    StringBuilder strSqlm2 = new StringBuilder();
        //    if (lmmodel.LIBRARY_ID != null)
        //    {
        //        strSqlm1.Append("LIBRARY_ID,");
        //        strSqlm2.Append("" + lmmodel.LIBRARY_ID + ",");
        //    }
        //    if (lmmodel.MATERIAL_ID != null)
        //    {
        //        strSqlm1.Append("MATERIAL_ID,");
        //        strSqlm2.Append("" + lmmodel.MATERIAL_ID + ",");
        //    }
        //    if (lmmodel.NUM != null)
        //    {
        //        strSqlm1.Append("NUM,");
        //        strSqlm2.Append("" + lmmodel.NUM + ",");
        //    }
        //    if (lmmodel.MINVALUE != null)
        //    {
        //        strSqlm1.Append("MINVALUE,");
        //        strSqlm2.Append("" + lmmodel.MINVALUE + ",");
        //    }
        //    strSqlm.Append("insert into T_PUB_LIBRARYMATERIAL(");
        //    strSqlm.Append(strSqlm1.ToString().Remove(strSqlm1.Length - 1));
        //    strSqlm.Append(")");
        //    strSqlm.Append(" values (");
        //    strSqlm.Append(strSqlm2.ToString().Remove(strSqlm2.Length - 1));
        //    strSqlm.Append(")");
        //    strSqlm.Append(";select @@IDENTITY");
        //    strArry.Add(strSqlm);
        //    #endregion

        //    DBHelper.ExecuteSqlTran(strArry);
        //}
        //#endregion


        #region 库存清单
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetMaterialList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,a.LIBRARY_ID,a.MATERIAL_ID,NUM,MINVALUE,BRANCH_NAME,LIBRARY_NAME,MATERIAL_NAME,d.FLAG ");
            strSql.Append(" FROM T_PUB_LIBRARYMATERIAL as a, T_PUB_BRANCH as b, T_PUB_LIBRARY as c, T_PUB_MATERIAL as d");
            strSql.Append(" where a.LIBRARY_ID = c.LIBRARY_ID and c.BRANCH_ID = b.BRANCH_ID and d.MATERIAL_ID = a.MATERIAL_ID");
            if (strWhere.Trim() != "")
            {
                strSql.Append(strWhere);
            }
            Database db = DatabaseFactory.CreateDatabase();
            return db.ExecuteDataSet(CommandType.Text, strSql.ToString());
        }
        #endregion

        #region  Method

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool ExistsMaterial(int? LID, int? MID)
        {
            Database db = DatabaseFactory.CreateDatabase();
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_PUB_LIBRARYMATERIAL where LIBRARY_ID=@LIBRARY_ID and MATERIAL_ID=@MATERIAL_ID");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); 
            db.AddInParameter(dbCommand, "LIBRARY_ID", DbType.Int32, LID);
            db.AddInParameter(dbCommand, "MATERIAL_ID", DbType.Int32, MID);
            int cmdresult;
            object obj = db.ExecuteScalar(dbCommand);
            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
            {
                cmdresult = 0;
            }
            else
            {
                cmdresult = int.Parse(obj.ToString());
            }
            if (cmdresult == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.LibrarySys.T_PUB_LIBRARYMATERIAL model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into T_PUB_LIBRARYMATERIAL(");
            strSql.Append("LIBRARY_ID,MATERIAL_ID,NUM,MINVALUE)");

            strSql.Append(" values (");
            strSql.Append("@LIBRARY_ID,@MATERIAL_ID,@NUM,@MINVALUE)");
            strSql.Append(";select @@IDENTITY");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "LIBRARY_ID", DbType.Int32, model.LIBRARY_ID);
            db.AddInParameter(dbCommand, "MATERIAL_ID", DbType.Int32, model.MATERIAL_ID);
            db.AddInParameter(dbCommand, "NUM", DbType.Double, model.NUM);
            db.AddInParameter(dbCommand, "MINVALUE", DbType.Double, model.MINVALUE);
            int result;
            object obj = db.ExecuteScalar(dbCommand);
            if (!int.TryParse(obj.ToString(), out result))
            {
                return 0;
            }
            return result;
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.LibrarySys.T_PUB_LIBRARYMATERIAL model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update T_PUB_LIBRARYMATERIAL set ");
            strSql.Append("LIBRARY_ID=@LIBRARY_ID,");
            strSql.Append("MATERIAL_ID=@MATERIAL_ID,");
            strSql.Append("NUM=@NUM,");
            strSql.Append("MINVALUE=@MINVALUE");
            strSql.Append(" where ID=@ID ");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, model.ID);
            db.AddInParameter(dbCommand, "LIBRARY_ID", DbType.Int32, model.LIBRARY_ID);
            db.AddInParameter(dbCommand, "MATERIAL_ID", DbType.Int32, model.MATERIAL_ID);
            db.AddInParameter(dbCommand, "NUM", DbType.Double, model.NUM);
            db.AddInParameter(dbCommand, "MINVALUE", DbType.Double, model.MINVALUE);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from T_PUB_LIBRARYMATERIAL ");
            strSql.Append(" where ID=@ID ");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void UpdateLibrary(Model.LibrarySys.T_PUB_LIBRARYMATERIAL model, Model.LibrarySys.T_PUB_LIBRARYOUT library)
        {
            ArrayList strArry = new ArrayList();
            StringBuilder strSql = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();
            if (model.LIBRARY_ID != null)
            {
                strSql1.Append("LIBRARY_ID,");
                strSql2.Append("" + model.LIBRARY_ID + ",");
            }
            if (model.MATERIAL_ID != null)
            {
                strSql1.Append("MATERIAL_ID,");
                strSql2.Append("" + model.MATERIAL_ID + ",");
            }
            if (model.NUM != null)
            {
                strSql1.Append("NUM,");
                strSql2.Append("" + model.NUM + ",");
            }
            strSql.Append("insert into T_PUB_LIBRARYMATERIAL(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strArry.Add(strSql);

            StringBuilder strSql3 = new StringBuilder();
            strSql3.Append("update T_PUB_LIBRARYOUT set ");
            if (library.BRANCH_ID != null)
            {
                strSql3.Append("BRANCH_ID=" + library.BRANCH_ID + ",");
            }
            else
            {
                strSql3.Append("BRANCH_ID= null ,");
            }
            if (library.LIBRARY_ID != null)
            {
                strSql3.Append("LIBRARY_ID=" + library.LIBRARY_ID + ",");
            }
            else
            {
                strSql3.Append("LIBRARY_ID= null ,");
            }
            if (library.APPLICANT != null)
            {
                strSql3.Append("APPLICANT=" + library.APPLICANT + ",");
            }
            if (library.APPLY_TIMEOUT != null)
            {
                strSql3.Append("APPLY_TIMEOUT='" + library.APPLY_TIMEOUT + "',");
            }
            else
            {
                strSql3.Append("APPLY_TIMEOUT= null ,");
            }
            if (library.REAL_TIMEOUT != null)
            {
                strSql3.Append("REAL_TIMEOUT='" + library.REAL_TIMEOUT + "',");
            }
            else
            {
                strSql3.Append("REAL_TIMEOUT= null ,");
            }
            if (library.PLAN_TIMEIN != null)
            {
                strSql3.Append("PLAN_TIMEIN='" + library.PLAN_TIMEIN + "',");
            }
            else
            {
                strSql3.Append("PLAN_TIMEIN= null ,");
            }
            if (library.REAL_TIMEIN != null)
            {
                strSql3.Append("REAL_TIMEIN='" + library.REAL_TIMEIN + "',");
            }
            else
            {
                strSql3.Append("REAL_TIMEIN= null ,");
            }
            if (library.STATE != null)
            {
                strSql3.Append("STATE='" + library.STATE + "',");
            }
            else
            {
                strSql3.Append("STATE= null ,");
            }
            if (library.REMARK != null)
            {
                strSql3.Append("REMARK='" + library.REMARK + "',");
            }
            else
            {
                strSql3.Append("REMARK= null ,");
            }
            if (library.TITEL != null)
            {
                strSql3.Append("TITEL='" + library.TITEL + "',");
            }
            else
            {
                strSql3.Append("TITEL= null ,");
            }
            if (library.APPLY_TIME != null)
            {
                strSql3.Append("APPLY_TIME='" + library.APPLY_TIME + "',");
            }
            else
            {
                strSql3.Append("APPLY_TIME= null ,");
            }
            if (library.ORDER_ID != null)
            {
                strSql3.Append("ORDER_ID=" + library.ORDER_ID + ",");
            }
            else
            {
                strSql3.Append("ORDER_ID= null ,");
            }
            if (library.NOTATION != null)
            {
                strSql3.Append("NOTATION='" + library.NOTATION + "',");
            }
            else
            {
                strSql3.Append("NOTATION= null ,");
            }
            if (library.APPROVER != null)
            {
                strSql3.Append("APPROVER=" + library.APPROVER + ",");
            }
            else
            {
                strSql3.Append("APPROVER= null ,");
            }
            int n = strSql3.ToString().LastIndexOf(",");
            strSql3.Remove(n, 1);
            strSql3.Append(" where ID=" + library.ID + "");
            strArry.Add(strSql3);
            DBHelper.ExecuteSqlTran(strArry);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        //public void UpdateMaterial(Model.LibrarySys.T_PUB_LIBRARYOUT model, Model.LibrarySys.T_PUB_LIBRARYMATERIAL LIBRARYMATERIALModeel)
        //{
        //    ArrayList strArry = new ArrayList();
        //    StringBuilder strSql = new StringBuilder();
        //    strSql.Append("update T_PUB_LIBRARYOUT set ");
        //    if (model.BRANCH_ID != null)
        //    {
        //        strSql.Append("BRANCH_ID=" + model.BRANCH_ID + ",");
        //    }
        //    else
        //    {
        //        strSql.Append("BRANCH_ID= null ,");
        //    }
        //    if (model.LIBRARY_ID != null)
        //    {
        //        strSql.Append("LIBRARY_ID=" + model.LIBRARY_ID + ",");
        //    }
        //    else
        //    {
        //        strSql.Append("LIBRARY_ID= null ,");
        //    }
        //    if (model.APPLICANT != null)
        //    {
        //        strSql.Append("APPLICANT=" + model.APPLICANT + ",");
        //    }
        //    if (model.APPLY_TIMEOUT != null)
        //    {
        //        strSql.Append("APPLY_TIMEOUT='" + model.APPLY_TIMEOUT + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("APPLY_TIMEOUT= null ,");
        //    }
        //    if (model.REAL_TIMEOUT != null)
        //    {
        //        strSql.Append("REAL_TIMEOUT='" + model.REAL_TIMEOUT + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("REAL_TIMEOUT= null ,");
        //    }
        //    if (model.PLAN_TIMEIN != null)
        //    {
        //        strSql.Append("PLAN_TIMEIN='" + model.PLAN_TIMEIN + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("PLAN_TIMEIN= null ,");
        //    }
        //    if (model.REAL_TIMEIN != null)
        //    {
        //        strSql.Append("REAL_TIMEIN='" + model.REAL_TIMEIN + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("REAL_TIMEIN= null ,");
        //    }
        //    if (model.STATE != null)
        //    {
        //        strSql.Append("STATE='" + model.STATE + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("STATE= null ,");
        //    }
        //    if (model.REMARK != null)
        //    {
        //        strSql.Append("REMARK='" + model.REMARK + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("REMARK= null ,");
        //    }
        //    if (model.TITEL != null)
        //    {
        //        strSql.Append("TITEL='" + model.TITEL + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("TITEL= null ,");
        //    }
        //    if (model.APPLY_TIME != null)
        //    {
        //        strSql.Append("APPLY_TIME='" + model.APPLY_TIME + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("APPLY_TIME= null ,");
        //    }
        //    if (model.ORDER_ID != null)
        //    {
        //        strSql.Append("ORDER_ID=" + model.ORDER_ID + ",");
        //    }
        //    else
        //    {
        //        strSql.Append("ORDER_ID= null ,");
        //    }
        //    if (model.NOTATION != null)
        //    {
        //        strSql.Append("NOTATION='" + model.NOTATION + "',");
        //    }
        //    else
        //    {
        //        strSql.Append("NOTATION= null ,");
        //    }
        //    if (model.APPROVER != null)
        //    {
        //        strSql.Append("APPROVER=" + model.APPROVER + ",");
        //    }
        //    else
        //    {
        //        strSql.Append("APPROVER= null ,");
        //    }
        //    int n = strSql.ToString().LastIndexOf(",");
        //    strSql.Remove(n, 1);
        //    strSql.Append(" where ID=" + model.ID + "");
        //    strArry.Add(strSql);

        //    StringBuilder strSql1 = new StringBuilder();
        //    strSql1.Append("update T_PUB_LIBRARYMATERIAL set ");
        //    if (LIBRARYMATERIALModeel.LIBRARY_ID != null)
        //    {
        //        strSql1.Append("LIBRARY_ID=" + LIBRARYMATERIALModeel.LIBRARY_ID + ",");
        //    }
        //    else
        //    {
        //        strSql1.Append("LIBRARY_ID= null ,");
        //    }
        //    if (LIBRARYMATERIALModeel.MATERIAL_ID != null)
        //    {
        //        strSql1.Append("MATERIAL_ID=" + LIBRARYMATERIALModeel.MATERIAL_ID + ",");
        //    }
        //    else
        //    {
        //        strSql1.Append("MATERIAL_ID= null ,");
        //    }
        //    if (LIBRARYMATERIALModeel.NUM != null)
        //    {
        //        strSql1.Append("NUM=" + LIBRARYMATERIALModeel.NUM + ",");
        //    }
        //    else
        //    {
        //        strSql1.Append("NUM= null ,");
        //    }
        //     n = strSql1.ToString().LastIndexOf(",");
        //    strSql1.Remove(n, 1);
        //    strSql1.Append(" where ID=" + LIBRARYMATERIALModeel.ID + "");
        //    strArry.Add(strSql1);
        //    DBHelper.ExecuteSqlTran(strArry);
        //}


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.LibrarySys.T_PUB_LIBRARYMATERIAL GetModel(int ID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,LIBRARY_ID,MATERIAL_ID,NUM,MINVALUE from T_PUB_LIBRARYMATERIAL ");
            strSql.Append(" where ID=@ID ");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);
            Model.LibrarySys.T_PUB_LIBRARYMATERIAL model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return model;
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.LibrarySys.T_PUB_LIBRARYMATERIAL GetModel(int bid, int mid)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,LIBRARY_ID,MATERIAL_ID,NUM,MINVALUE from T_PUB_LIBRARYMATERIAL ");
            strSql.Append(" where LIBRARY_ID=@LIBRARY_ID and  MATERIAL_ID=@MATERIAL_ID");
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "LIBRARY_ID", DbType.Int32, bid);
            db.AddInParameter(dbCommand, "MATERIAL_ID", DbType.Int32, mid);
            Model.LibrarySys.T_PUB_LIBRARYMATERIAL model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,LIBRARY_ID,MATERIAL_ID,NUM,MINVALUE ");
            strSql.Append(" FROM T_PUB_LIBRARYMATERIAL ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            Database db = DatabaseFactory.CreateDatabase();
            return db.ExecuteDataSet(CommandType.Text, strSql.ToString());
        }

        /// <summary>
        /// 获得数据列表（比DataSet效率高，推荐使用）
        /// </summary>
        public List<Model.LibrarySys.T_PUB_LIBRARYMATERIAL> GetListArray(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,LIBRARY_ID,MATERIAL_ID,NUM,MINVALUE ");
            strSql.Append(" FROM T_PUB_LIBRARYMATERIAL ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<Model.LibrarySys.T_PUB_LIBRARYMATERIAL> list = new List<Model.LibrarySys.T_PUB_LIBRARYMATERIAL>();
            Database db = DatabaseFactory.CreateDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
                while (dataReader.Read())
                {
                    list.Add(ReaderBind(dataReader));
                }
            }
            return list;
        }


        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Model.LibrarySys.T_PUB_LIBRARYMATERIAL ReaderBind(IDataReader dataReader)
        {
            Model.LibrarySys.T_PUB_LIBRARYMATERIAL model = new Model.LibrarySys.T_PUB_LIBRARYMATERIAL();
            object ojb;
            ojb = dataReader["ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ID = (int)ojb;
            }
            ojb = dataReader["LIBRARY_ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.LIBRARY_ID = (int)ojb;
            }
            ojb = dataReader["MATERIAL_ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.MATERIAL_ID = (int)ojb;
            }
            ojb = dataReader["NUM"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.NUM = Convert.ToInt32(ojb);
            }
            ojb = dataReader["MINVALUE"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.MINVALUE = Convert.ToInt32(ojb);
            }
            return model;
        }

        #endregion  Method
    }
}
